Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find_library: Centralize functionality here #4

Closed
wants to merge 6 commits into from

Conversation

EricCousineau-TRI
Copy link

@EricCousineau-TRI EricCousineau-TRI commented Mar 25, 2019

Signed-off-by: Eric Cousineau eric.cousineau@tri.global

Towards #3; downstream PRs:

Some questions:

  • What header extensions should I use? Some code, like rclcpp, uses *.hpp; however, this and other repos sometimes use .h for C++ code.
  • What copyright belongs here? The existing stuff had Amazon; I set the new stuff to OSRF, but I dunno. If it's author-based, I can set TRI.

@dirk-thomas Would you be able to review this bit?


Repositories:

repositories:
  rcpputils:
    type: git
    url: git@github.com:EricCousineau-TRI/rcpputils.git
    version: issue/3
  rmw_implementation:
    type: git
    url: git@github.com:EricCousineau-TRI/rmw_implementation.git
    version: issue/rcpputils_3
  rosidl_typesupport:
    type: git
    url: git@github.com:EricCousineau-TRI/rosidl_typesupport.git
    version: issue/rcpputils_3


This change is Reviewable

Addresses #3

@emersonknapp
Copy link
Contributor

Would you mind updating the README to mention this new utility?

@EricCousineau-TRI
Copy link
Author

Done. TBH, though, trying to include API + usage documentation in the README, instead of a header file, doesn't sound like an extremely scalable solution. (I tried to minimize duplication, b/c redundancy seems brittle here, as the docs aren't tested / autogenerated?)

At what point would there be generated API docs for these pages? (Those API docs could then have more descriptions on usage, examples, etc.)
(Should I file an issue?)

CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Show resolved Hide resolved
@EricCousineau-TRI
Copy link
Author

Also, I have WIP commits here; if / when this is approved, can I have a chance to curate the commits and get rid of the WIP cruft?

Copy link

@thomas-moulard thomas-moulard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll let Dirk being the final judge there, but a few more ideas / suggestions.

src/find_library.cpp Outdated Show resolved Hide resolved
src/find_library.cpp Outdated Show resolved Hide resolved
src/find_library.cpp Outdated Show resolved Hide resolved
src/find_library.cpp Show resolved Hide resolved
src/find_library.cpp Outdated Show resolved Hide resolved
src/find_library.cpp Outdated Show resolved Hide resolved
src/find_library.cpp Outdated Show resolved Hide resolved
src/find_library.cpp Outdated Show resolved Hide resolved
src/find_library.cpp Outdated Show resolved Hide resolved
test/test_find_library.cpp Show resolved Hide resolved
Copy link

@thomas-moulard thomas-moulard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@dirk-thomas actually I am also interested by the answer to Eric's question. Which name should be put in those copyright headers?

Copy link
Member

@dirk-thomas dirk-thomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What header extensions should I use?

ROS 2 uses .h / .c for C code and .hpp / .cpp for C++ code.

Other code in this repo which doesn't conform to that convention should be updated in a separate PR (FYI @emersonknapp).

What copyright belongs here??

For the code parts which have been moved from other repositories the original copyright should be kept as it was (I assume OSRF). For any newly written code you should probably use your own name/company for the copyright.

CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
include/rcpputils/find_library.hpp Outdated Show resolved Hide resolved
include/rcpputils/find_library.hpp Show resolved Hide resolved
include/rcpputils/find_library.hpp Outdated Show resolved Hide resolved
@emersonknapp
Copy link
Contributor

The existing code that had the wrong extensions was fixed in #6

@dirk-thomas
Copy link
Member

dirk-thomas commented Apr 25, 2019

@EricCousineau-TRI Assuming you also want to remove the implementation from the current location in favor of this central one this change is subject to the upcoming API freeze (May 2nd). If you would like this change to be part of Dashing please update the patch based on the feedback. The branch also needs to be rebased due to other merged PRs in the meantime.

@dirk-thomas
Copy link
Member

Assuming you also want to remove the implementation from the current location in favor of this central one this change is subject to the upcoming API freeze (May 2nd).

@@EricCousineau-TRI Friendly ping.

@EricCousineau-TRI
Copy link
Author

Sorry for the delay! Addressed comments.

Merge commit is a028f34. Will rebase and squash for simplicity.

@EricCousineau-TRI EricCousineau-TRI force-pushed the issue/3 branch 3 times, most recently from bdee68c to b575b19 Compare May 2, 2019 05:56
@EricCousineau-TRI
Copy link
Author

Done. Trying to fix failures in rcpputils.copyright.include/rcpputils/visibility_control.hpp by pattern-matching against split.hpp.

@EricCousineau-TRI
Copy link
Author

Eh, just copied and pasted license noticed for BSD. For some reason, seemed like it was sensitive to whitespace???

This was the patch that effectively let it pass from Job 6 to Job 7:
https://gist.github.com/EricCousineau-TRI/d11882c208781f9929169c340087f2f5

Signed-off-by: Eric Cousineau <eric.cousineau@tri.global>
@dirk-thomas
Copy link
Member

Thanks for the updated:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

The Windows build is failing and warns about inconsistent linkage - the API needs visibility macros.

Signed-off-by: Eric Cousineau <eric.cousineau@tri.global>
@EricCousineau-TRI
Copy link
Author

Ah, oops! Tried fixing it, modeling CMake defs after rosidl_typesupport_cpp.

@dirk-thomas
Copy link
Member

  • Windows Build Status

@EricCousineau-TRI
Copy link
Author

Failed with the following:

LINK : fatal error LNK1181: cannot open input file 'Release\test_library.lib' [C:\J\workspace\ci_windows\ws\build\rcpputils\test_find_library.vcxproj]
  Building Custom Rule C:/J/workspace/ci_windows/ws/src/ros2/rcpputils/CMakeLists.txt

Can I ask if you know what the fix is here?

@dirk-thomas
Copy link
Member

No .lib file is being generated for the test_library since it doesn't export any symbols. You need to export at least one symbol.

Signed-off-by: Eric Cousineau <eric.cousineau@tri.global>
@EricCousineau-TRI
Copy link
Author

Ah, makes sense, thanks! One more time!

namespace test_library
{

RCPPUTILS_PUBLIC
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs an #include of the header containing the macro definition.

Please rebuild the package locally and run tests when making changes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah... oops! Done.

Signed-off-by: Eric Cousineau <eric.cousineau@tri.global>
@dirk-thomas
Copy link
Member

Windows: Build Status

Signed-off-by: Dirk Thomas <dirk-thomas@users.noreply.github.com>
@dirk-thomas
Copy link
Member

Windows: Build Status

@dirk-thomas
Copy link
Member

target_link_libraries(test_find_library ${PROJECT_NAME} test_library)
set_tests_properties(test_find_library PROPERTIES
ENVIRONMENT
"_TEST_LIBRARY_DIR=$<TARGET_FILE_DIR:test_library>;_TEST_LIBRARY=$<TARGET_FILE:test_library>")
Copy link
Author

@EricCousineau-TRI EricCousineau-TRI May 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sigh... I'm thinking that Windows CMake or something else is maybe failing here? (in that it only passes the directly, not the full path?)
I've recently gotten a Windows machine (for another purpose), but will see if I can dig in a bit more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That being said, thank you for your patience thus far!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to get this setup on Windows, but not being a Windows developer, to try and reproduce this bug is very time consuming and frustrating.

Is there some free Azure container / VM service that has ROS 2 provisioned, that I could possible connect to so that I can debug from there? (For me and other developers, who do not wish to spend time / money setting up Windows environments?)

And can you point me to a unittest that does this sort of thing successfully?
(Something more explicit than saying "Hey, it loaded the library, cool.")

If there isn't one already, I may just shortcut this for now and special-case the Windows logic to pass on CI by acknowledging the current bug (which I'm still confident is CMake, pending any other evidence to the contrary).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently the test fails with:

C:\J\workspace\ci_windows\ws\src\ros2\rcpputils\test\test_find_library.cpp(58): error: Expected equality of these values:
  test_lib_actual
    Which is: "C:/J/workspace/ci_windows/ws/build/rcpputils/Release/test_library.dll"
  test_lib_expected
    Which is: "C:/J/workspace/ci_windows/ws/build/rcpputils/Release"

Your test code retrieves two environment variables: first the library path then the library dir. But you are missing the fact that the second call overwrites the first variable. See the API documentation of that function: https://github.com/ros2/rcutils/blob/9af59e871e0bfaadb0cbb32014a7167efb9760c0/include/rcutils/get_env.h#L27-L29

So the value of the first environment variable must be copied to its own memory before fetching the second. See ed7b9fa for the fix.

@nuclearsandwich
Copy link
Member

@EricCousineau-TRI are you interested in updating and moving forward with this PR or should we close it out?

@EricCousineau-TRI
Copy link
Author

Sorry! I'm interested in moving it forward, but haven't had the chance to focus on it just yet. I should be able to get to it within a couple of months. (I can close it temporarily if it makes it easier for task tracking.)

@nuclearsandwich
Copy link
Member

No need to close it. I've applied the backlog label which means that our team will no longer be checking it on a regular basis. When you're ready for 🔍 please let us know that you need another round of review and we can peel off the backlog label once it's active.

@dirk-thomas
Copy link
Member

I created #25 which rebased this PR as well as fixes the remaining issue on Windows. Therefore I will go ahead and close this ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants